Week 01: Introduction & the Cool Programming Language

How to Run the Program

  • Compiler (Offline)
    • $Program \rightarrow Compiler \rightarrow Execute$
    • $Data \rightarrow Execute \rightarrow Output$
  • Interpreter (Online)
    • $Program + Data \rightarrow Interpreter \rightarrow Output$

Compiler Concept

  • (Syntactic) Lexical Analysis
    • Concept: Divide program text into words or tokens.
    • Input: text
    • Output: words or tokens
    • Sample Input: if x == y then z = 1; else z = 2;
    • Sample Output: #IF #ID(x) #EQAUL #ID(y) #THEN ...
  • (Syntactic) Parsing
    • Concept: Diagramming Sentences.
    • Input: Tokens
    • Output: Abstruct Semantic Tree
    • Sample Input: #INT(5) #PLUS #INT(3) #MULTIPLY #INT(5)
    • Sample Output: (#PLUS (#INT(5)) (#MULTIPLY (#INT(3)) (#INT(5))))
  • (Types scope) Semantic Analysis
    • Concept: Catch inconsistencies.
    • Sample Input: { int Jack=3; { int Jack=4; cout << Jack; } }
    • Question: What is the value?
  • Optimization
    • Concept: Run faster/Use less memory/Use low power/network.
  • (Translation) Code Generation
    • Concept: Produce assembly code.
  • Why are there so many programming languages?
    • Application domains have distinct/conflicting needs.
  • Why are there new programming languages?
    • Programming training is the dominant cost for a programming language.
    • Wild-used languages are slow to change.
    • Easy to start a new language: when productivity > training cost
    • Languages adopted to fill a void. (Void means new techniques.)
  • What is a good programming languages?
    • There is no universally accepted metric for language design.

In [ ]: